<%@ page language="java" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/view/common/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
    <title>${appname}-<c:if test="${!empty sessionScope._local_node_session}">${sessionScope._local_node_session.nodeName}-</c:if>${si:ctname("NET_TYPE",sessionScope._netType)}</title>
    <%@ include file="/WEB-INF/view/common/css_js_ace.jsp" %>
    <link rel="stylesheet" href="${ctx}/static/ace/css/chosen.css"/>
    <script type="text/javascript">
        function submit() {
            $("#searchForm").submit();
        }
        function reset_ftp_password(id) {
        	if(!window.confirm("确定将所选ftp用户密码重置为初始密码吗，重置后Ftp客户端需要重新登录！")){
        		return;
        	}
            $.ajax({
                type: "POST",
                url:_ctx + "/exch/reset_ftp_password/" + id + ".do",
                success: function (resp) {
                    if (resp.status == '1') {
                        ui.msg(resp.msg, 1);
                    } else {
                        ui.msg(resp.msg, 0);
                    }
                },
                error: function () {
                    ui.msg('信息加载错误', 0);
                }
            });
        }
        function openFtp(){
        	 $.jsonGet({
        		 url:_ctx + "/exch/open_ftp.do",
        		 jsonStatusSuccessCall:function(msg){
        			 alert(msg);
        			 jQuery.refresh();
        		 },
        		 jsonStatusFailCall:function(msg){
        			 alert(msg);
        		 }
        	 });
        }
    </script>
</head>
<body>
<%@ include file="/WEB-INF/view/common/topbar.jsp" %>
<div class="main-container" id="main-container">
    <div class="main-container-inner">
        <%@ include file="/WEB-INF/view/common/sidebar.jsp" %>
        <div class="main-content">
            <div class="breadcrumbs" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li>
                        <i class="icon-home home-icon"></i>
                        <a href="#">首页</a>
                    </li>
                    <li><a href="#">交换管理</a></li>
					<li><a href="#">传输通道管理</a></li>
                    <li class="active">FTP资源分配</li>
                </ul>
            </div>
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="widget-box">
                            <div class="widget-header widget-header-flat">
                                <h5 class="smaller lighter grey">
                                    <i class="icon-desktop"></i> &nbsp;&nbsp;FTP基本信息
                                </h5>
                                <div class="widget-toolbar">
                                    <a href="#" data-action="collapse"> <i class="icon-chevron-up"></i> </a>
                                </div>
                            </div>
                            <div class="widget-body">
                                <div class="widget-main">
									<div class="profile-user-info profile-user-info-striped">
										<div class="profile-info-row">
											<div class="profile-info-name">FTP类型</div>
											<div class="profile-info-value">
											<span class="editable">
											 内嵌
											</span>
											</div>
										</div>
										<div class="profile-info-row">
											<div class="profile-info-name">端口</div>
											<div class="profile-info-value">
											<span class="editable">${locaFtpInfo.port}&nbsp;</span>
											</div>
										</div>
										<div class="profile-info-row">
											<div class="profile-info-name">FTP根目录</div>
											<div class="profile-info-value">
											<span class="editable">${locaFtpInfo.rootDir}&nbsp;</span>
											</div>
										</div>
										<div class="profile-info-row">
											<div class="profile-info-name">最大用户数</div>
											<div class="profile-info-value">
											<span class="editable">${locaFtpInfo.maxLogins}&nbsp;</span>
											</div>
										</div>
										<div class="profile-info-row">
											<div class="profile-info-name">状态</div>

                                            <div class="profile-info-value">
                                            <c:if test="${'2' == locaFtpInfo.status }">
                                                <span class="editable red tipMe pointer" title="FTP目前处于停止状态，您可以通过下面的启动FTP按钮启动FTP"><i class="icon-warning-sign"></i> ${si:ctname("OPENCLOSE",locaFtpInfo.status)}&nbsp;</span>
                                            </c:if>
                                            <c:if test="${'1' == locaFtpInfo.status }">
                                                <span class="editable green tipMe pointer" title="FTP目前处于正常工作状态"><i class="icon-ok"></i>${si:ctname("OPENCLOSE",locaFtpInfo.status)}&nbsp;</span>
                                            </c:if>
                                            <c:if test="${'1' != locaFtpInfo.status && '2' != locaFtpInfo.status}">
                                                ${si:ctname("OPENCLOSE",locaFtpInfo.status)}&nbsp;
                                            </c:if>

											<%--<span class="editable">${si:ctname("OPENCLOSE",locaFtpInfo.status)}&nbsp;</span>--%>
											</div>
										</div>
										<c:if test="${locaFtpInfo.status eq 1}">
											<div class="profile-info-row">
												<div class="profile-info-name">启动时间</div>
												<div class="profile-info-value">
												<span class="editable">${si:fmtDate(locaFtpInfo.lastStartTime)}&nbsp;</span>
												</div>
											</div>
										</c:if>
										<div class="profile-info-row">
											<div class="profile-info-name">操作</div>
											<div class="profile-info-value">
											<c:if test="${locaFtpInfo.status eq 0}">
												<a href="javascript:void(0)" onclick="openFtp()" class="btn btn-xs btn-success" title="启动FTP">
													<i class="icon-play"></i> 启动FTP
												</a>
											</c:if>
											<a href="javascript:void(0)" onclick="javascript:$.refresh();" class="btn btn-xs btn-primary" title="刷新">
													<i class="fa fa-refresh"></i> 刷新 
											</a>
											 &nbsp;
											</div>
										</div>
										</div>
                                    </div>
                            </div>
                            </div>
                        <div class="widget-box">
							<h4 class="header smaller lighter blue">
							<i class="icon-sign-blank blue"></i>&nbsp;&nbsp;FTP用户信息
							</h4>
                            <div class="widget-header header-color-white">
                                <div class="widget-toolbar no-border">

                                </div>
                            </div>
                            
                            <div class="widget-body">
                                <div class="widget-main">
                                    <form id="searchForm" class="form-search"
                                          action="${ctx }/exch/ftp_mgr.do" method="post"
                                          onsubmit="return search(this)">
                                        <div class="row">
                                            <div class="col-xs-4">
                                                <div class="input-group">
                                                    <span class="input-group-addon" id="yewu">适配器名称</span>
                                                    <select name="searchName" id="searchName"  class="form-control search-query">
                                                        <option value="">请选择</option>
                                                        <c:forEach var="vo" items="${adapterList}">
                                                            <option value='${vo.adapterCode}'
                                                                    <c:if test="${vo.adapterCode==param.searchName}">selected</c:if>>${vo.adapterName}</option>
                                                        </c:forEach>
                                                    </select>
                                                     <span class="input-group-btn">
															<button type="submit" class="btn btn-purple btn-sm"
                                                                    onclick="return formSubmit();" style="height:32px;">
                                                                <i class="icon-search icon-on-right bigger-110"></i>
                                                              搜索
                                                            </button>
                                                     </span>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="hr hr12 hr-dotted"></div>
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th class="center">序号</th>
                                    <th>FTP用户名</th>
                                    <th>所属适配器</th>
									<th>在线状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach var="vo" items="${_data}" varStatus="idx">
                                    <tr>
                                        <td class="center">${idx.index + 1}</td>
                                        <td>${vo.userid}</td>
                                        <td> ${si:adaptorName(vo.userid)}（${vo.userid}）</td>
                                        <td> ${vo.onlineShowStr}</td>
                                        <td>
                                            <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
                                                <a class="blue" href="javascript:void(0)"
                                                   onclick="reset_ftp_password('${vo.userid}')" title="重置密码">
                                                    <i class="icon-undo bigger-130"></i>
                                                </a>
                                                <a class="green"
                                                   href="${ctx }/exch/ftp_password_update/${vo.userid}.do" title="修改密码">
                                                    <i class="icon-edit bigger-130"></i>
                                                </a>
                                            </div>

                                        </td>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                            <jsp:include page="/WEB-INF/view/common/pg.jsp">
                                <jsp:param value="${ctx }/exch/ftp_mgr.do" name="url"/>
                                <jsp:param value="${_total}" name="total"/>
                                <jsp:param value="${_urlpara}" name="urlpara"/>
                            </jsp:include>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
